package com.example.yls.demoa;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.ArrayAdapter;
import android.widget.ListView;

import java.util.ArrayList;
import java.util.List;

public class MainActivity extends AppCompatActivity {
    private ListView listView ;
    private List<Student> studentList = new ArrayList<Student>();
    String data[] = {"蔡和弟","黎相涛","蔡焕涛","巫祖榕"};
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        initStudent();
        StudentAdapter adapter = new StudentAdapter
                (MainActivity.this,R.layout.student_item,studentList);
        listView = findViewById(R.id.list_view);
        listView.setAdapter(adapter);
    }

    void initStudent(){
        studentList.add(new Student(R.drawable.dog1,"黎相涛"));
        studentList.add(new Student(R.drawable.dog2,"蔡焕涛"));
        studentList.add(new Student(R.drawable.dog3,"巫祖榕"));
        studentList.add(new Student(R.drawable.dog4,"黎相涛"));
        studentList.add(new Student(R.drawable.dog5,"蔡焕涛"));

    }
}
